#ifndef KMKMUSIC_H
#define KMKMUSIC_H

#include <QWidget>
#include <QMouseEvent>
#include <QPoint>
#include <QDebug>
#include <QGraphicsDropShadowEffect>
#include <QMovie>
#include <QJsonArray>
#include <QJsonObject>
#include <QFile>
#include <QFileDialog>
#include "recbox.h"
#include "commanpage.h"
#include "volumetool.h"
#include "musiclist.h"
#include "musicslider.h"
#include "lrcpage.h"
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <QPropertyAnimation>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QMessageBox>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QMainWindow>
#include "mlabel.h"

QT_BEGIN_NAMESPACE
namespace Ui { class kmkMusic; }
QT_END_NAMESPACE

class kmkMusic : public QWidget
{
    Q_OBJECT

public:
    kmkMusic(QWidget *parent = nullptr);
    ~kmkMusic();

    void initUi();
    void initPlay();

    void initSqlite();
    void initMusicList();

private slots:
    void on_quit_clicked();
    void onKmkMusicQuit();
    void mousePressEvent(QMouseEvent *event);
    void mouseMoveEvent(QMouseEvent*event);

    void connectSignalAndSlots();
    void onBtFormClick(int id);

    QJsonArray setRecTextAndImage();
    void on_min_clicked();

    void on_volume_clicked();

    void on_addLocal_clicked();

    void updateLikeMusicAndPage(bool isLike,const QString&musicId);

    void on_play_clicked();

    void on_playUp_clicked();

    void on_playDown_clicked();

    void on_playMode_clicked();

    void onPlayAllClick(MusicPageType pageType);

    void onPlayMusicByIndex(CommanPage*page,int index);

    void playAllMusicOfPage(CommanPage*page,int index);

    void onCurrentIndexChanged(int index);

    void onPlaybackModeChanged(QMediaPlaylist::PlaybackMode mode);

    void onPlayStatusChanged();

    void onMutedClick(bool isMuted);

    void onSetVolumeVal(int volumeVal);

    void onDurationChanged(qint64 duration);

    void onPositionChanged(qint64 position);

    void onMusicSliderChanged(float rate);

    void onMetaDataAvailableChanged(bool available);
    void on_lrcWord_clicked();
    void onMoreSet(QMenu*menu,int width,int height);

    void onMoreItemPlayClick(const QString &musicId);
    void onMoreItemNextClick(const QString &musicId);
    void onMoreItemDeleteClick(const QString &musicId);
    void onMoreItemCommendClick(const QString &musicId);

signals:
    void playStart(int index);
private:
    Ui::kmkMusic *ui;
    QPoint dragPosition;
    VolumeTool *volTool;
    MusicList *musicList;
    QMediaPlayer *mediaPlayer;
    QMediaPlaylist *playList;
    CommanPage *currentPage;
    int currentIndex;
    qint64 totalTime;

    QPropertyAnimation *lrcPageAnime;
    LrcPage *lrcPage;

    QSqlDatabase sqlite;
    bool isDrag;
    QPoint pos;

};
#endif // KMKMUSIC_H
